<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page isELIgnored="false" %>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="author" content="order by dede58.com"/>
    <title>个人信息</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="format-detection" content="telephone=no">
    <link rel="stylesheet" type="text/css" href="common/layui/css/layui.css" media="all">
    <link rel="stylesheet" type="text/css" href="common/bootstrap/css/bootstrap.css" media="all">
    <link rel="stylesheet" type="text/css" href="common/global.css" media="all">
    <link rel="stylesheet" type="text/css" href="css/personal.css" media="all">
    <script type="text/javascript" src="js/jquery2.js"></script>
</head>
<body>
<section class="layui-larry-box">
    <div class="larry-personal">
        <header class="larry-personal-tit">
            <span>添加职位</span>
        </header><!-- /header -->
        <div class="larry-personal-body clearf//ix">
            <form class="layui-form col-lg-5" id="jobFrom">
                <div class="layui-form-item">
                    <label class="layui-form-label">职位编号</label>
                    <div class="layui-input-block">
                        <input type="text" id="number" name="number" autocomplete="off" value="" class="layui-input"
                               placeholder="输入职位编号">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">职位名称</label>
                    <div class="layui-input-block">
                        <input type="text" name="name" id="name" value="" autocomplete="off" class="layui-input"
                               placeholder="输入职位名称">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">对应职务</label>
                    <div class="layui-input-block">
                        <select class="layui-select" name="ductId" id="duct_id" style="display: block; width: 170px"
                                lay-filter="aihao">
                            <option value="">--请选择--</option>
                        </select>
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">所属部门</label>
                    <div class="layui-input-block">
                        <select class="layui-select" name="deptId" id="dept_id" style="display: block; width: 170px"
                                lay-filter="aihao">
                            <option value="">--请选择--</option>
                        </select>
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">编制人数</label>
                    <div class="layui-input-block">
                        <input type="text" name="wren" id="wren" value="" autocomplete="off" class="layui-input"
                               placeholder="输入编制人数">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">职位说名</label>
                    <div class="layui-input-block">
                        <input type="text" name="winfo" id="winfo" autocomplete="off" class="layui-input"
                               placeholder="输入职位说名">
                    </div>
                </div>
            </form>
            <div class="layui-form-item">
                <div class="layui-input-block">
                    <button class="layui-btn" id="sub">立即提交</button>
                </div>
            </div>
        </div>
    </div>
</section>
<script type="text/javascript" src="common/layui/layui.js"></script>
<script>
    $(function () {
        /**
         * 查询职务表渲染界面
         */
        $.ajax({
            type: "get",
            url: "duc/queryDcuTypeAll",
            dataType: "json",
            success: function (data) {
                $.each(data, function (index, da) {
                    var options = $("<option value='" + da.id + "'>" + da.zname + "</option>");
                    $("#duct_id").append(options);
                });
            },
            error: function () {
                window.location.href = "404.jsp";
            }
        });

        /**
         * 查需部门
         */
        $.ajax({
            type: "get",
            url: "dept/queryAll",
            dataType: "json",
            success: function (data) {
                $.each(data, function (index, da) {
                    var options = $("<option value='" + da.id + "'>" + da.dname + "</option>");
                    $("#dept_id").append(options);
                });
            },
            error: function () {
                window.location.href = "404.jsp";
            }
        });

        $("#sub").on("click", function () {
            if ($("#number").val() == "" || $("#number").val() == null) {
                alert("请填写职位编号");
                return;
            }
            if ($("#name").val() == "" || $("#name").val() == null) {
                alert("请填写职位名称");
                return;
            }
            if ($("#duct_id").val() == "" || $("#duct_id").val() == null) {
                alert("请选择对应职务");
                return;
            }
            if ($("#dept_id").val() == "" || $("#dept_id").val() == null) {
                alert("请选择对应部门");
                return;
            }
            if ($("#wren").val() == "" || $("#wren").val() == null) {
                alert("请填写编制人数");
                return;
            }
            if ($("#winfo").val() == "" || $("#winfo").val() == null) {
                alert("请填写编制人数");
                return;
            }
            $.ajax({
                type: "get",
                url: "job/insertJob",
                data: $("#jobFrom").serialize(),
                dataType: "json",
                success: function () {
                    window.location.href = "showJob.jsp";
                },
                error: function () {
                    window.location.href = "404.jsp";
                }
            });
        });
    })
</script>
</body>
</html>